{% extends 'admin/admin_base.html' %}

{% block content %}
<div class="container mt-4">
    <h2>测试管理</h2>
    
    <!-- 筛选表单 -->
    <div class="card mb-4">
        <div class="card-body">
            <form method="get" class="row g-3">
                <div class="col-md-4">
                    <label for="student_name" class="form-label">学生姓名</label>
                    <input type="text" class="form-control" id="student_name" name="student_name" value="{{ request.args.get('student_name', '') }}">
                </div>
                <div class="col-md-4">
                    <label for="school" class="form-label">学校</label>
                    <select class="form-control" id="school" name="school">
                        <option value="">全部</option>
                        <option value="府东校区" {% if request.args.get('school') == '府东校区' %}selected{% endif %}>府东校区</option>
                        <option value="兴华校区" {% if request.args.get('school') == '兴华校区' %}selected{% endif %}>兴华校区</option>
                    </select>
                </div>
                <div class="col-md-4 d-flex align-items-end">
                    <button type="submit" class="btn btn-primary">筛选</button>
                    <a href="{{ url_for('admin.test_management') }}" class="btn btn-secondary ms-2">重置</a>
                </div>
            </form>
        </div>
    </div>

    <!-- 结果表格 -->
    <div class="table-responsive">
        <table class="table table-striped table-hover">
            <thead class="table-light">
                <tr>
                    <th>试卷名称</th>
                    <th>学生姓名</th>
                    <th>学校</th>
                    <th>得分</th>
                    <th>提交时间</th>
                </tr>
            </thead>
            <tbody>
                {% for submission in submissions %}
                <tr>
                    <td>
                        <a href="{{ url_for('admin.test_detail', exam_id=submission.exam_id, submission_id=submission._id) }}" class="text-primary">
                            {{ submission.exam_name }}
                        </a>
                    </td>
                    <td>{{ submission.student_name }}</td>
                    <td>{{ submission.school }}</td>
                    <td>{{ submission.score }}</td>
                    <td>{{ submission.submit_time.strftime('%Y-%m-%d %H:%M:%S') if submission.submit_time else '' }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}
